package com.miyake.loveviewweb.client.main;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;

public class Startup extends Composite implements HasText {

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }
    private static StartupUiBinder uiBinder = GWT.create(StartupUiBinder.class);
    @UiField Button buttonLogin;
    @UiField Button buttonCreate;
    private StartupListener startupListener;
    private String loginUrl;

    interface StartupUiBinder extends UiBinder<Widget, Startup> {
    }

    public Startup(StartupListener listener) {
        initWidget(uiBinder.createAndBindUi(this));
        this.startupListener = listener;
    }

    public Startup(String firstName) {
        initWidget(uiBinder.createAndBindUi(this));
    }

    public void setText(String text) {
  
    }

    public String getText() {
        return "";
    }

    @UiHandler("buttonLogin")
    void onButtonLoginClick(ClickEvent event) {
        Window.Location.assign(this.loginUrl);
        //this.startupListener.onLogin();
    }
    @UiHandler("buttonCreate")
    void onButtonCreateClick(ClickEvent event) {
        this.startupListener.onCreateAccount();
    }
}
